/*
 * Kongzhi.h
 *
 *  Created on: 2022年7月9日
 *      Author: wocao
 *  存儲體控制抽象類，包含基本的存儲體控制函數
 */
#include "../cunchu_quanju.h"
#ifndef CUNCHUTI_KONGZHI_KONGZHI_H_
#define CUNCHUTI_KONGZHI_KONGZHI_H_

class Kongzhi {

public:
	mutex mutex_cu;
	mutex mutex_bitview;
	mutex mutex_bityu;
	virtual void add_cunchuti(const string &path) = 0;				//添加存儲體
	virtual void rem_cunchuti(string &path) = 0;				//刪除存儲體
	virtual void charu(char *str, unsigned long kuai_num, int size) = 0; //按塊號寫入，str為指向要寫入的數據的數組指針，kuai_num為塊號，size為要寫入的數據大小
	virtual char* quchu(unsigned long kuai_num, int size) = 0; //按塊讀取數據，kuai_num為塊號，size為要讀取的數據大小
	virtual unsigned long get_firstkuai_num(int size) = 0; //獲取第一個有連續size大小的區域，返回第一個塊的塊號,沒有此大小的塊返回-1
	virtual num_add dizhizhuanhuan(unsigned long kuai_num) = 0;	//地址轉換方法，未找到地址返回0
	virtual void bitview_fanzhuan(unsigned long kuai_num, char ft) = 0;	//位圖翻轉方法，第一個參數為塊號，第二個參數傳1置1，傳0置0
	virtual unsigned long get_all_size() = 0;
	virtual unsigned long get_used_size() = 0;
	virtual double get_used_baifenbi() = 0;
	virtual void ser_all_size() = 0;
	virtual void ser_used_size() = 0;
	virtual ~Kongzhi() = 0;
};

#endif /* CUNCHUTI_KONGZHI_KONGZHI_H_ */
